﻿using WorldView;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using DrawableObjects.Actors;
using System.Collections.Generic;
using DrawableObjects.Actors.Weapons;
using DrawableObjects.Actors.Projectiles;
using DrawableObjects.Actors.Aircrafts;
using GlobalGameClasses;
using Microsoft.Xna.Framework;
using Serialization;

namespace InSovietRussiaProgrammTestsYou
{
    
    
    /// <summary>
    ///Dies ist eine Testklasse für "GenericDrawableListTest" und soll
    ///alle GenericDrawableListTest Komponententests enthalten.
    ///</summary>
    [TestClass()]
    public class GenericDrawableListTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Ruft den Testkontext auf, der Informationen
        ///über und Funktionalität für den aktuellen Testlauf bietet, oder legt diesen fest.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Zusätzliche Testattribute
        // 
        //Sie können beim Verfassen Ihrer Tests die folgenden zusätzlichen Attribute verwenden:
        //
        //Mit ClassInitialize führen Sie Code aus, bevor Sie den ersten Test in der Klasse ausführen.
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Mit ClassCleanup führen Sie Code aus, nachdem alle Tests in einer Klasse ausgeführt wurden.
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Mit TestInitialize können Sie vor jedem einzelnen Test Code ausführen.
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Mit TestCleanup können Sie nach jedem einzelnen Test Code ausführen.
        [ClassCleanup()]
        public static void MyClassCleanup()
        {
            GlobalGameValues.Values.achievementsUnlocked = new List<Achievement>();
            GlobalGameValues.Values.content = new ContentCollection();
            GlobalGameValues.Values.difficulty = null;
            GlobalGameValues.Values.errorWriter = null;
            GlobalGameValues.Values.gameTime = new GameTime();
            GlobalGameValues.Values.GlobalStrings = new StringContainer();
            GlobalGameValues.Values.graphicsDevice = null;
            GlobalGameValues.Values.score = new InterfaceComponents.HUDWrapper<int>(new List<InterfaceComponents.HUDComponent>());
            GlobalGameValues.Values.soundPlayer = null;
            GlobalGameValues.Values.spriteBatch = null;
            GlobalGameValues.Values.volume_Music = 0;
            GlobalGameValues.Values.volume_soundEffect = 0;
        }
        //
        #endregion


        /// <summary>
        ///Ein Test für "getActors"
        ///</summary>
        [TestMethod()]
        public void getActorsTest()
        {
            GenericDrawableList target = new GenericDrawableList();
            Actor a = FabricatableAircraft.GET_ENEMY_1(Microsoft.Xna.Framework.Matrix.Identity);
            a.owner = Owner.ENEMY;
            target.addActor(a);
            Actor b = FabricatableAircraft.GET_ENEMY_1(Microsoft.Xna.Framework.Matrix.Identity);
            b.owner = Owner.PLAYER;
            target.addActor(b);
            Actor c = Plasma.GET_PLASMA_ENEMY(0, Microsoft.Xna.Framework.Color.White);
            c.owner = Owner.ENEMY;
            target.addActor(c);
            Actor d = WeaponUpgrade.GET_UPGRADEITEM(Weapon.WeaponType.Missile);
            d.owner = Owner.PLAYER;
            target.addActor(d);
            Type T = typeof(Aircraft);
            Owner owner = Owner.PLAYER;
            List<Actor> expected = new List<Actor>();
            expected.Add(b);
            List<Actor> actual;
            actual = target.getActors(T, owner);
            Assert.AreEqual(expected[0], actual[0]);
        }

        /// <summary>
        ///Ein Test für "getActors"
        ///</summary>
        [TestMethod()]
        public void getActorsTest1()
        {
            GenericDrawableList target = new GenericDrawableList();
            Actor a = FabricatableAircraft.GET_ENEMY_1(Microsoft.Xna.Framework.Matrix.Identity);
            a.owner = Owner.ENEMY;
            target.addActor(a);
            Actor b = FabricatableAircraft.GET_ENEMY_1(Microsoft.Xna.Framework.Matrix.Identity);
            b.owner = Owner.PLAYER;
            target.addActor(b);
            Actor c = Plasma.GET_PLASMA_ENEMY(0, Microsoft.Xna.Framework.Color.White);
            c.owner = Owner.ENEMY;
            target.addActor(c);
            Actor d = WeaponUpgrade.GET_UPGRADEITEM(Weapon.WeaponType.Missile);
            d.owner = Owner.PLAYER;
            target.addActor(d);
            Type T = typeof(Aircraft);
            List<Actor> expected = new List<Actor>();
            expected.Add(a);
            expected.Add(b);
            List<Actor> actual;
            actual = target.getActors(T);
            Assert.AreEqual(expected.Count, actual.Count);
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
            T = typeof(Projectile);
            expected = new List<Actor>();
            expected.Add(c);
            actual = target.getActors(T);
            Assert.AreEqual(expected.Count, actual.Count);
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
            T = typeof(Item);
            expected = new List<Actor>();
            expected.Add(d);
            actual = target.getActors(T);
            Assert.AreEqual(expected.Count, actual.Count);
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }

        /// <summary>
        ///Ein Test für "addActor"
        ///</summary>
        [TestMethod()]
        public void addActorTest()
        {
            GenericDrawableList target = new GenericDrawableList();
            Actor a = FabricatableAircraft.GET_ENEMY_1(Microsoft.Xna.Framework.Matrix.Identity);
            target.addActor(a);
            Actor b = Plasma.GET_PLASMA_ENEMY(0, Microsoft.Xna.Framework.Color.White);
            target.addActor(b);
            Actor c = HealingBeam.GET_HEALING_BEAM_DRONE();
            target.addActor(c);
            Type T = typeof(Projectile);
            List<Actor> expected = new List<Actor>();
            expected.Add(b);
            expected.Add(c);
            List<Actor> actual = target.getActors(T);
            Assert.AreEqual(expected.Count, actual.Count);
            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
    }
}
